<!doctype html>
<html>
<head>
<meta charset="utf-8">

<link href="../../css/e-style.css" rel='stylesheet' type='text/css'>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<script type="text/javascript" src="../tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
    selector: "textarea"
 });
</script>
<?php

include('../../php/db.php');

$getvariable =  $_GET['refid'];

echo $getvariable;

$getid = mysql_query("SELECT * FROM `flss`.`employer` WHERE `refid` = '$getvariable' ") or die(mysql_error());
while($rowshow = mysql_fetch_array($getid))
{
	$getemid = $rowshow['employer_id'];
}

$getcname = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getcname2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getcname3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getrow2 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getrow3 = mysql_query("SELECT * FROM `flss`.`employer` WHERE `employer_id` = '$getemid' ") or die(mysql_error);
$getrow4 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow5 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow6 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow7 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow8 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow9 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);
$getrow10 = mysql_query("SELECT * FROM `flss`.`e_snap` WHERE `e_id` = '$getemid' ") or die(mysql_error);

$countjob = mysql_query("SELECT Count(*) as Count FROM `flss`.`job_order` where `employer_ID` = '$getemid' ") or die(mysql_error());
$count = mysql_fetch_assoc($countjob);
$cjob = $count['Count'];

$getalljob = mysql_query("SELECT * FROM `flss`.`job_order` where `employer_ID` = '$getemid' ") or die(mysql_error());

while($employerrowphoto = mysql_fetch_array($getcname3))
{
  $clogo = $employerrowphoto['logo'];
  $ccover = $employerrowphoto['cover'];
}


$logo = empty($clogo) ? DEFAULT_LOGO : IMAGE_URL_SMALL.$clogo; 
$cover = empty($ccover) ? DEFAULT_COVER : IMAGE_URL_SMALL.$ccover;


?>

        
<title>
					<?php  while ($ename = mysql_fetch_array($getcname2)) {
						 echo $ename['ename'];
    				}  ?> 
</title>
        
        
</head>
<body>

<div class="h-top">
<div class="h-top-logo">

<a href="../../index.php"> <img src="../../images/handlogo.png" height="50"> </a>
 
</div>

</div>
<div class="b-sub-container">
	<div class="b-content">
	
    	<div class="b-image-upload">
    		<img id="companyCover" width = "960" height = "250" src="<?=$cover?>"/>
    		
        </div>
       
	<div class="b-sub-content">
        <div class="b-company-logo">
		<img id="companyLogo" width = "150" height = "150" src="<?=$logo?>"/>
        
        </div>
		<div class="b-company-name-container">
    		<div class="b-company-name" >
        		<div  style="font-size:18px; margin-left:10px;" name="companyname">
					<?php  while ($row = mysql_fetch_array($getcname)) {
						 echo $row['ename'];
    				}  ?> 
                </div> 
        	</div>
		</div>
        <div class="b-company-overview-container">
        	<div class="b-company-overview">
        		<div class="b-company-overview-content">
					<div  class="b-company-overview-title" name="companyoverview"> Company Overview </div>
        			<div class="b-company-overview-context" name="companyoverviewcontext"> 
                    		<?php  while ($row2 = mysql_fetch_array($getrow2)) {
			 						echo $row2['description'];
    						}  ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="b-company-why-container">
        	<div class="b-company-why">
        		<div class="b-company-why-content">
                	<div class="b-company-why-title" name="companywhy"> Why Join Us </div>
        			<div class="b-company-why-context" name="companywhycontext">
                    		<?php  while ($row3 = mysql_fetch_array($getrow3)) {
			 						echo $row3['whyjoinus'];
    						}  ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="b-company-postedjobs-container">
       		<div class="b-company-postedjobs">
       			    <h2 style="margin-left:10px;">All Jobs from This Company</h2>
        				<span style="float:left; font-weight:bold;">Displaying  to  of <?php echo $cjob; ?> jobs</span>
                        <span style="float:right;">
                        	<div class="row">
                        		<div class="rPaging">
                            	</div>
                            </div>
                         </span>      
			 </div>
         </div>
         
         <div>
             <table class="tstyle">
                   <tr style="line-height: 34px;background: #F9F9F9;border-bottom: 1px solid #CCC;width: 640px;margin-top: 15px;font-weight: bold;">
                        <td style="padding-left: 5px; width:20%;" valign="center" align="center"><b>Date Posted</b></td>
                        <td style="padding-left: 5px; width:40%;" align="center" ><b>Job Title</b></td>
                        <td style="padding-left: 5px; width:10%;" valign="center" align="center"><b>Needed Applicant</b></td>
                        <td style="padding-left: 5px; width:30%;" valign="center" align="center"><b>Action</b></td>
                        
                        </tr>
                       <?php while($job = mysql_fetch_assoc($getalljob)) { ?>
                        <tr>
                        	<td>
                            <?php $result = $job['date_posted']; 
								$dtime = new DateTime($job['date_posted']);
								print $dtime->format("D, F d, Y");	
								?>
                            </td>
                        	<td style="font-weight: bold;"><?php 
							$jt = $job['Title'];
							$refid = $job['refid'];
                            ?>
							<a style="cursor:pointer;" href="../Job/joborder.php?refid=<?php echo $refid; ?>" onClick="window.open(this.href,'popupwindow','left=200,top=50,width=1000,height=600,scrollbars=yes,menu=0,status=0'); return false;">  
							<?php
                            echo $jt; 
							?>
							</a> 
							</td>
                        	<td align="center">
                            <?php echo $job['numapps']; ?>
                            </td>
                            <?php if($job['status'] == "3") { ?> 
                            <td align="center">
                                <span> <input job_id="<?=$job['job_id']?>" type="submit" value="Accept" name="accept" class="btnAccept" >   <input job_id="<?=$job['job_id']?>" class="btnDecline" type="submit" value="Decline" name="decline" id="decline" >
                                </span>
                            </td>
                            <?php }else if($job['status'] == "1") {  ?>
                            <td align="center">
                                <span> Accepted
                                </span>
                            </td>
                            <?php }else if($job['status'] == "2") {  ?>
                                <td align="center">
                                <span> Declined
                                </span>
                            </td>
                            <?php }?>
                        </tr>
                        <?php } ?>
                        </table>
                       
         	</div>
    </div>
    
				    	

    <div class="b-company-right">
    	
        <div class="b-company-snap-container">
			<div class="b-company-snap">
            	<div class="b-company-snap-content">
                	<div  style="font-size:18px; margin-left:10px;" name="companysnap"> Company Snapshot </div>
                    	<div class="tstyle">
                        <table height="250">
                        <tr>
                        <td>Registration No: </td>
                        <td><?php  while ($row4 = mysql_fetch_array($getrow4)) {
						 echo $row4['Registration_No'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Industry: </td>
                        <td><?php  while ($row5 = mysql_fetch_array($getrow5)) {
						 echo $row5['Industry'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Company Size: </td>
                        <td><?php  while ($row6 = mysql_fetch_array($getrow6)) {
						 echo $row6['Company_size'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Working Hours: </td>
                        <td><?php  while ($row7 = mysql_fetch_array($getrow7)) {
						 echo $row7['Working_hours'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Dress Code: </td>
                        <td><?php  while ($row8 = mysql_fetch_array($getrow8)) {
						 echo $row8['Dresscode'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Benefits </td>
                        <td><?php  while ($row9 = mysql_fetch_array($getrow9)) {
						 echo $row9['Benefits'];
    				}  ?>  </td>
                        </tr>
                        <tr>
                        <td>Spoken Language(s): </td>
                        <td><?php  while ($row10 = mysql_fetch_array($getrow10)) {
						 echo $row10['Spoken_language'];
    				}  ?>  </td>
                        </tr>


                        </table>
                        </div>
                </div>
            </div>
        </div>
        
        <div class="b-company-map-container">
        	<div class="b-company-map">
               <div class="b-company-map-content">
                <div  style="font-size:18px; margin-left:10px;" name="companyloc"> Company Location </div>	
                <div style="margin-top:10px; margin-left:10px;">
                <?php
				$getmap = mysql_fetch_array(mysql_query("SELECT * FROM e_map WHERE employer_id = '$getemid'"));
				echo $getmap['e_address'];
				?>
               </div>
             </div>
        </div>
        </div>  
    </div>	



</div>
</div>


		<div class="footer">
        	
            <div style="margin-top:20px; float:left; width:100%;">
            <center>
            
            <p>Copyright @ Famous Labor Supply Service Alright Reserve 2015</p>
            </center>
            </div>
        </div>   

<script type="text/javascript">

    $(function(){
        function accept_decline_post(job_id,status)
        {
           return  $.ajax({
                    url : '../../api/accept_decline_employer_post.php',
                    data: {job_id:job_id,status:status},
                    dataType: 'json',
                    type: 'post',
                });
        }
        $(document).ready(function(){
            $(document).on('click','.btnAccept',function(){
                var job_id = $(this).attr('job_id');
                //$(this).parent().css("border","5px solid red");
                r = confirm("Are you sure you want to accept this post?");
                if(r)
                {
                    var parent = $(this).parent();
                    var previous = parent.html();
                    parent.html("Loading please wait <img src='../../images/Loading.gif'/>");
                    accept_decline_post(job_id,"1").done(function(result){
                        if(result.status)
                        {
                            parent.html("Accepted");
                        }
                        else
                        {
                            alert("Error please try again");
                            parent.html(previous);
                        }
                    });
                }
            });

            $(document).on('click','.btnDecline',function(){
                var job_id = $(this).attr('job_id');
                //$(this).parent().css("border","5px solid red");
                r = confirm("Are you sure you want to decline this post?");
                if(r)
                {
                    var parent = $(this).parent();
                    var previous = parent.html();
                    parent.html("Loading please wait <img src='../../images/Loading.gif'/>");
                    accept_decline_post(job_id,"2").done(function(result){
                        if(result.status)
                        {
                            parent.html("Declined");
                        }
                        else
                        {
                            alert("Error please try again");
                            parent.html(previous);
                        }
                    });
                }
            });
        });
    });
</script>

</body>
</html>
